<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>在线鲜花销售网</title>
<meta name="keywords" content="鲜花，鲜花速递，鲜花网，花店，开业花篮" />
<meta name="description" content="各种鲜花绿植，应有尽有" />
<link href="images/xicon.png" rel="shortcut icon" type="image/x-icon" />
<link href="css/header.css" rel="stylesheet" type="text/css" />
<link href="css/index.css" rel="stylesheet" type="text/css" />
<link href="css/footer.css" rel="stylesheet" type="text/css" />
</head>

<body>
<!-- 顶部区域 -->
<header id="header">
	<!-- 顶部标题区域 -->
	<div class="htitle">
    	<a href="#" target="_blank" class="location">衡阳</a>
        
        <div class="header-info">
            <div class="login-info">
            	
            </div>
            
            <div class="person-info">
            	<span>|</span>
            	<a href="order.html" target="_blank">我的订单</a>
                <span>|</span>
                <a href="#" target="_blank">我的鲜花</a>
                <span>|</span>
                <a href="#" target="_blank">客户服务</a>
                <span>|</span>
           		<a href="#" target="_blank">个人信息</a>
            </div>
        
        </div>
    </div>
    
    <!-- 顶部搜索区域 -->
    <div class="search">
    	<div class="search_left">
    		<a href="index.html" title="首页">
            	<img src="images/logo.png" width="260px" height="120px"/> 
            </a>
        </div>
        
        <div class="search_right">
        	<div class="search_top">
                <div class="search_div">
                    <input type="search" class="search-ipt" placeholder="请输入要搜索的内容" />
                    <input type="button" class="search-btn"  onclick = "searchGoods()"/>  
                </div>
                <div class="buycart">
                	<i class="iconfont">0</i>
                    <a href="cart.html" target="_blank" onclick="toCart()">我的购物车</a>
                </div>
            </div>
            
            <div class="search_item" id="search_item">   
            </div>
        </div>
    </div>
</header>

<div class="slide">
	<ul class="slide_pics">
        <li><a href="" class=""><img src="images/banner1.jpg" alt="幻灯片"></a></li>
        <li><a href="" class=""><img src="images/banner2.jpg" alt="幻灯片"></a></li>
    </ul>
    <div class="prev"></div>
    <div class="next"></div>
    <ul class="points"></ul>
</div>
<div class="intro">
	<div class="wrap">
		<ul class="clearfix">
			<li class="iconbounce">
				<div class="pic">
					<img src="images/intro01.png" >
				</div>
				<div class="txt">
					<p>鲜花电商平台</p>
					<span>10年平台，用心做好鲜花服务</span>
				</div>
			</li>
			<li class="iconbounce">
				<div class="pic">
					<img src="images/intro02.png" >
				</div>
				<div class="txt">
					<p>鲜花实拍展示</p>
					<span>敢展现送前实拍的鲜花网</span>
				</div>
			</li>
			<li class="iconbounce">
				<div class="pic">
					<img src="images/intro03.png" >
				</div>
				<div class="txt">
					<p>1-2小时送花</p>
					<span>全国连锁，3小时送1000城市</span>
				</div>
			</li>
			<li class="iconbounce">
				<div class="pic">
					<img src="images/intro04.png" >
				</div>
				<div class="txt">
					<p>售后服务</p>
					<span>全国可靠的售后保障</span>
				</div>
			</li>
		</ul>
	</div>
</div>

<article>
    <div class="view_title">
    	<a href="" class="view_price price_down">价格</a>
        <input type="number" id="start_price" class="price_ipt" min="1"/>
        <span>-</span>
        <input type="number" id="end_price" class="price_ipt" min="1"/>
    </div>
	
	<!-- 展示商品信息 -->
    <div class="view_goods">
    	<ul id="view_goods">
        	
     
        </ul>
    </div>
    
    <div class="page_info">
       
    </div>
</article>
<div class="popup_con">
	<div class="popup">
		<p id="popup_info"></p>
	</div>
</div>  
<footer>
	<div class="fservice">
		<ul class="clearfix">
			<li>
				<span>
					<img src="images/f01.png" >
					<a href="#">热诚服务</a>
				</span>
			</li>
			<li><span><img src="images/f02.png" ><a href="#">客户信赖</a></span></li>
			<li><span><img src="images/f03.png" ><a href="#">时尚原创花艺</a></span></li>
			<li><span><img src="images/f04.png" ><a href="#">订单实拍</a></span></li>
			<li><span><img src="images/f05.png" ><a href="#">优惠多多</a></span></li>
			<li><span><img src="images/f06.png" ><a href="#">1小时配送</a></span></li>
			<li><span><img src="images/f07.png" ><a href="#">售后服务</a></span></li>
		</ul>
	</div>
	
	
	<div class="foot_link">
        <a href="#">关于我们</a> <span> | </span>
        <a href="#">联系我们</a> <span> | </span>
        <a href="#">招聘广告</a> <span> | </span>
        <a href="#">友情链接</a>
    </div>
    <p>CopyRight &copy; 2021 <a class="copy" href="#" target="_blank">点心思在线鲜花销售系统</a> All Rights Reserverd</p>
    <p>电话：0734-7572842 湘ICP备12345678号-1</p>
</footer>
<script src="js/jquery-3.4.1.min.js" type="text/javascript"></script>
<script src="js/jquery-ui.min.js" type="text/javascript"></script>
<script src="js/slide.js" type="text/javascript"></script>
<script src="js/checkLogin.js" type="text/javascript"></script>
<script src="js/addCart.js" type="text/javascript"></script>
<script>
let page = 1;
let row = 5;
let totalPage = 1;
//直接发送ajax
$.post("goods",{
	op: 'findFirst',
	page: page,
	row: row
},function(data){
	//首先，计算一下最大页数
						//向上取整			//总数量					一页多少条
	totalPage = Math.ceil( data[data.length-1].total / row );
	//显示分页下标
	showPage();
	//显示数据
	showGoods(data);
},"json");

//显示分页下标
function showPage(){
	let str = '<a href="javascript:void(0)"  onclick="findByPage(this,1)">首页</a>';
	for(let i = 1; i <= totalPage; i++){
		if( i == page ){
			str +=' <a href="javascript:void(0)" class="active"  onclick="findByPage(this,'+i+')">'+i+'</a>';
		}else{
			str +='<a href="javascript:void(0)"  onclick="findByPage(this,'+i+')">'+i+'</a>';
		}
	}
	//也判断一下
	if(page == totalPage){
		str += '<a href="javascript:void(0)"  onclick="findByPage(this,'+totalPage+')">末页</a>';
	}else{
		str += '<a href="javascript:void(0)" onclick="findByPage(this,'+totalPage+')">末页</a>';
	}
	
	//放入到网页中
	$(".page_info").html(str);
}

//查询商品
function searchGoods(){
	let gname = $(".search-ipt").val();
	//商品的查询，价格的查询，按照类别的查询，都放到一起
	let sprice = $("#start_price").val();
	let eprice = $("#end_price").val();
	let tno = $("#search_item>a[class=selected]").data("id");
	
	$.post("goods",{
		op: 'findFirst',
		page: page,
		row: row,
		gname: gname,
		sprice: sprice,
		eprice: eprice,
		tno: tno
	},function(data){
		//首先，计算一下最大页数
		//向上取整			//总数量					一页多少条
		totalPage = Math.ceil( data[data.length-1].total / row );
		//显示分页下标
		showPage();
		//显示数据
		showGoods(data);
	},"json");
}

//分页查找数据
function findByPage(obj,flag){
	//节省一下流量
	if( $(obj).hasClass("active") ){
		return;
	}
	
	//改变Class
	$(obj).parent().find(".active").removeClass("active");
	$(obj).addClass("active");
	
	page = flag;
	$.post("goods",{
		op: 'finds',
		page: page,
		row: row
	},function(data){
		//显示数据
		showGoods(data);
	},"json");
}

//显示数据
function showGoods(data){
	let str = '';
	$.each(data,function(index,item){
		if( item.pics == null ){
			return;
		}
		let pic = item.pics.split(";")[0].split("_")[1];
		str +=`<li class="hot_box">
				    	<i class="all_i i_t"></i>
						<i class="all_i i_r"></i>
						<i class="all_i i_b"></i>
						<i class="all_i i_l"></i>
				        <a href="detail.html#${item.gno}" target="_blank" class="hot_warp">
				        	<img src="images/goods/${pic}" title="鲜花"/>
				            <span>${item.gname}</span>
				        </a>
				        <div class="view_info">
				        	<span class="price">${item.price}</span>
				            <span>/${item.weight}</span>
				            <span class="buy" onclick="addCart(${item.gno})">&nbsp;</span>
				        </div>
	    			</li>`;
	});
	
	//放入到网页中
	$("#view_goods").html(str);
}
function toCart(){
    if( $(".login-info a").html() == "您好，请登录" ){
        alert("请先登录");
        location.href = "login.html";
        return;
    }
    location.href = "cart.html";
}

/* function addCart() {
	$("#popup_info").text("加入购物车成功...");
	$('.popup_con').fadeIn('fast', function() {
		setTimeout(function(){
			$('.popup_con').fadeOut('fast',function(){
			});	
		}, 2000)
	});
} */
</script>

</body>
</html>
